package demo;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

class Person implements Serializable {

    private static final long serialVersionUID = 2L;
    public String name;
    public Person(String name) {
        this.name = name;
    }
}

/**
* 
* @author : feixiang.li
* @since : 2025-06-12 20:25
*/
public class MyTest100 {
    public static void main(String[] args) {
//        Person person = new Person("张三");
//        System.out.println(person.name);
//        ObjectOutputStream outputStream = null;
//        try {
//            outputStream = new ObjectOutputStream(new FileOutputStream("/Users/luckincoffee/Desktop/code/java-test/demo1/src/main/resources/person.txt"));
//            outputStream.writeObject(person);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        Person person = null;
        try {
            person = (Person) new ObjectInputStream(new FileInputStream("/Users/luckincoffee/Desktop/code/java-test/demo1/src/main/resources/person.txt")).readObject();
            System.out.println(person.name);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
